import type { ApiRequest } from '@/types/apis.d'
import type { IManagerData } from '@/types/permission/manager'
import { request } from '../index'
export interface PermissionRequest {
  //权限管理
  'manager.list': {
    limit: number
    offset: number
    sort?: number
    order?: number
  }
  //管理员登录
  'manager.login': {
    username: string
    password: string
    code: string
  }
  //管理员登录验证码
  'manager.loginCode': {
    code: string
  }
  //添加管理员
  'manager.add': {
    user_name: string
    remark: string
    status: number
  }
  //获取管理员信息
  'manager.info': {
    admin_id: string
  }
  'manager.delete': {
    admin_id: string
  }
  //更新管理员
  'manager.update': {
    admin_id: string
    remark: string
    status: number
  }
  //重置管理员密码
  'manager.reset': {
    admin_id: string
    newPassword: string
  }
  //修改管理员密码
  'manager.updatePwd': {
    admin_id: string
    old_password: string
    new_password: string
    affirm_password: string
  }
  //上传
  'manager.upload': {}
  //多图上传
  'manager.multiple_upload': {}
}
//登录
export const login = (data?: ApiRequest['manager.login']) => request.post<'manager.login', any>('v1/admin/login', data)
//登录验证码
export const loginCode = (params?: ApiRequest['manager.loginCode']) =>
  request.get<'manager.loginCode', { code: any }>('v1/admin/login/code', params)
//管理员列表
export const list = (params?: ApiRequest['manager.list']) =>
  request.get<'manager.list', IManagerData[]>('v1/admin/list', params)
//添加管理员
export const add = (data?: ApiRequest['manager.add']) => request.post<'manager.add', any>('v1/admin/add', data)
//删除管理员
export const del = (data?: ApiRequest['manager.delete']) => request.post<'manager.delete', any>('v1/admin/delete', data)
//更新管理员
export const update = (data?: ApiRequest['manager.update']) =>
  request.post<'manager.update', any>('v1/admin/update', data)
//获取管理员信息
export const info = (params?: ApiRequest['manager.info']) =>
  request.get<'manager.info', IManagerData[]>(`v1/admin/info`, params)
//重置管理员密码
export const reset = (data?: ApiRequest['manager.reset']) =>
  request.post<'manager.reset', any>('v1/admin/reset_password', data)
//修改管理员密码
export const updatePwd = (data?: ApiRequest['manager.updatePwd']) =>
  request.post<'manager.updatePwd', any>('v1/admin/update_password', data)
//上传
export const upload = (data?: ApiRequest['manager.upload']) =>
  request.post<'manager.upload', any>('v1/common/img/upload', data)
//多图片上传
export const multiple_upload = (data?: ApiRequest['manager.upload']) =>
  request.post<'manager.upload', any>('v1/common/img/multi_upload', data)
